//
//  MTScreenView.m
//  met
//
//  Created by 李晓俊 on 2019/5/14.
//  Copyright © 2019 李晓俊. All rights reserved.
//

#import "MTScreenView.h"

@implementation MTScreenView
{
    
    CGRect myframe;
    
}
- (MTScreenView  *)initWithFrame:(CGRect)frame

{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray *nibs=[[NSBundle mainBundle]loadNibNamed:@"MTScreenView" owner:nil options:nil];
        self=[nibs objectAtIndex:0];
        myframe = frame;

        NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
        NSString *sex = [userDefault objectForKey:@"sex"];
        if ([sex isEqualToString:@"1"]) {
            self.manBut.selected = YES;
            self.womanBut.selected = NO;
            self.allBut.selected = NO;
            self.isSelect = @"1";
        }else if ([sex isEqualToString:@"2"]) {
            self.manBut.selected = NO;
            self.womanBut.selected = YES;
            self.allBut.selected = NO;
            self.isSelect = @"2";
        }else if ([sex isEqualToString:@"3"]) {
            self.manBut.selected = NO;
            self.womanBut.selected = NO;
            self.allBut.selected = YES;
            self.isSelect = @"3";
        }else {
            self.manBut.selected = NO;
            self.womanBut.selected = NO;
            self.allBut.selected = YES;
            self.isSelect = @"3";
        }
    }
    return self;
}
-(void)drawRect:(CGRect)rect

{
    self.frame=myframe;//关键点在这里
}
- (IBAction)butClick:(UIButton *)sender {
    sender.highlighted = NO;

    if (sender == self.manBut) {
        self.manBut.selected = YES;
        self.womanBut.selected = NO;
        self.allBut.selected = NO;
        self.isSelect = @"1";
    }else if (sender == self.womanBut) {
        self.manBut.selected = NO;
        self.womanBut.selected = YES;
        self.allBut.selected = NO;
        self.isSelect = @"2";

    }else if (sender == self.allBut) {
        self.manBut.selected = NO;
        self.womanBut.selected = NO;
        self.allBut.selected = YES;
        self.isSelect = @"3";
    }
}

- (IBAction)doneClick:(id)sender {
    if (self.screenClick) {
        self.screenClick(self.isSelect);
    }
}

@end
